package com.zhongzhi.common;

import java.awt.List;
import java.beans.PropertyChangeSupport;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Timer;

import org.apache.log4j.Logger;

import com.sun.org.apache.xpath.internal.operations.Bool;
import com.zhongzhi.bean.Configuration;
import com.zhongzhi.springboot.pojo.Computers;
import com.zhongzhi.springboot.pojo.Equipment;
import com.zhongzhi.springboot.pojo.EquipmentShow;
import com.zhongzhi.springboot.pojo.Station;
import com.zhongzhi.springboot.pojo.StationShow;
import com.zhongzhi.thread.PlcThread;
import com.zhongzhi.thread.TaskTherad;

import ch.qos.logback.classic.joran.action.LoggerAction;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TabPane;
import javafx.stage.WindowEvent;
import lombok.Data;
/**
 * 公共资源类
 * @author Administrator
 * 公共资源类存放了公共资源,多线程之间由于通信困难,因此采用了此类
 * 有些线程将参数放入此类,有些则将参数取出
 *
 */
public  class Common {
	/**计算机信息集合*/
	private static ArrayList<Computers> arrayList = new ArrayList<Computers>();
	/**plc基本信息*/
	private static  ArrayList<EquipmentShow> equipmentList;
	/**公共窗口对象(菜单切换画面用)*/
	private static ScrollPane sp;
	/**当前选择工位具体监控标记(挖掘机具体监控画面用)*/
	private static Integer SelectStation;
	/**当前选择的plc(tab画面的子画面用)*/
	private static Plc plc;
	/**当前挖掘机寻址(tab画面的子画面用)*/
	private static Integer grup;
	/**挖掘机从详细页面返回到纵览页面,选择的默认页面*/
	private static Integer page;
	/**tabpane公共对象*/
	private static TabPane tp;
	/**TaskTherad线程对象*/
	private static HashMap<Integer,TaskTherad> taskTherads = new HashMap<Integer, TaskTherad>();
	/**PlcThread线程对象*/
	private static HashMap<Integer,PlcThread> plcThread = new HashMap<Integer, PlcThread>();
	/**本台电脑所连接plc信息*/
	private static  HashMap<Integer,EquipmentShow> equipmentMap = new HashMap<Integer, EquipmentShow>();
	/**本台电脑所连接的工位信息*/
	private static  HashMap<Integer,Station> taskStationMap = new HashMap<Integer, Station>();
	/**tabs是否有更新*/
	private static Boolean tabsbool =  new Boolean(false);
	/**时间集合*/
	private static ArrayList<Timer> timelist = new ArrayList<Timer>();
	/**时间格式*/
	private static SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	/**新增工位选项按钮选择的plc*/
	private static Equipment plcItemEquipment = null;
	/**本机站号*/
	private static Configuration configuration= new Configuration();
	/**关闭窗口*/
	private static  WindowEvent event;
	/**弹出连接窗口状态*/
	private static boolean havaPage = false;
	
	
	public static boolean isHavaPage() {
		return havaPage;
	}
	public static void setHavaPage(boolean havaPage) {
		Common.havaPage = havaPage;
	}
	public static ArrayList<EquipmentShow> getEquipmentList() {
		return equipmentList;
	}
	public static void setEquipmentList(ArrayList<EquipmentShow> equipmentList) {
		Common.equipmentList = equipmentList;
	}
	public static ScrollPane getSp() {
		return sp;
	}
	public static void setSp(ScrollPane sp) {
		Common.sp = sp;
	}
	public static Integer getSelectStation() {
		return SelectStation;
	}
	public static void setSelectStation(Integer selectStation) {
		SelectStation = selectStation;
	}
	public static Plc getPlc() {
		return plc;
	}
	public static void setPlc(Plc plc) {
		Common.plc = plc;
	}
	/**此方法须有安全锁*/
	public static synchronized Integer getGrup() {
		return grup;
	}
	/**此方法须有安全锁*/
	public static synchronized void setGrup(Integer grup) {
		Common.grup = grup;
	}
	/**此方法须有安全锁*/
	public static synchronized void addGrup() {
		grup++;
	}
	public static Integer getPage() {
		return page;
	}
	public static void setPage(Integer page) {
		Common.page = page;
	}
	public static TabPane getTp() {
		return tp;
	}
	public static void setTp(TabPane tp) {
		Common.tp = tp;
	}
	public static HashMap<Integer, TaskTherad> getTaskTherads() {
		return taskTherads;
	}
	public static void setTaskTherads(HashMap<Integer, TaskTherad> taskTherads) {
		Common.taskTherads = taskTherads;
	}
	public static HashMap<Integer, EquipmentShow> getEquipmentMap() {
		return equipmentMap;
	}
	public static void setEquipmentMap(HashMap<Integer, EquipmentShow> equipmentMap) {
		Common.equipmentMap = equipmentMap;
	}
	
	public static HashMap<Integer, Station> getTaskStationMap() {
		return taskStationMap;
	}
	public static void setTaskStationMap(HashMap<Integer, Station> taskStationMap) {
		Common.taskStationMap = taskStationMap;
	}
	public static Boolean getTabsbool() {
		return tabsbool;
	}
	public static void setTabsbool(Boolean tabsbool) {
		Common.tabsbool = tabsbool;
	}
	public static ArrayList<Timer> getTimelist() {
		return timelist;
	}
	public static void setTimelist(ArrayList<Timer> timelist) {
		Common.timelist = timelist;
	}
	
	public static String getDateTimeString(Long l) {
		return format.format(l);
	}
	public static Equipment getPlcItemEquipment() {
		return plcItemEquipment;
	}
	public static void setPlcItemEquipment(Equipment plcItemEquipment) {
		Common.plcItemEquipment = plcItemEquipment;
	}
	public static SimpleDateFormat getFormat() {
		return format;
	}
	public static void setFormat(SimpleDateFormat format) {
		Common.format = format;
	}
	public static ArrayList<Computers> getArrayList() {
		return arrayList;
	}
	public static void setArrayList(ArrayList<Computers> arrayList) {
		Common.arrayList = arrayList;
	}
	public static Configuration getConfiguration() {
		return configuration;
	}
	public static void setConfiguration(Configuration configuration) {
		Common.configuration = configuration;
	}
	public static WindowEvent getEvent() {
		return event;
	}
	public static void setEvent(WindowEvent event) {
		Common.event = event;
	}
	public static HashMap<Integer, PlcThread> getPlcThread() {
		return plcThread;
	}
	public static void setPlcThread(HashMap<Integer, PlcThread> plcThread) {
		Common.plcThread = plcThread;
	}
	
	
	
}
